package com.a.aapp

import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.NetworkUtils
import com.blankj.utilcode.util.NetworkUtils.NetworkType
import com.blankj.utilcode.util.NetworkUtils.OnNetworkStatusChangedListener
import com.example.myframe.App
import com.example.myframe.http.RequestHandler
import com.a.lib_utils.TipUtil.toast
import com.example.myprint.PrintApp
import com.example.wmhouse_c_app.GlobalApplication
import com.example.wmhouse_c_app.data.UrlUtil
import com.example.wmhouse_c_app.data.pojo.Employee
import com.example.wmhouse_c_app.utils.XmlUtil
import com.tencent.mmkv.MMKV

class App : App() {
    var employee: Employee? = null

    var distDeptID //厂区ID
            : String? = null
    val APP_VERSION = 1.0f

    //    public static String blueToothMacAddress = "";//保存正在连接的蓝牙设备的mac地址
    val IS_PRINT_BY_PDA = true


    override fun onCreate() {
        super.onCreate()
        ARouter.init(this)
        ARouter.getInstance().build("/c/LoginActivity").navigation()
        PrintApp.init(this)
        if (!XmlUtil.hadTag("DistDeptID")) {
            XmlUtil.writeFileSdcard("DistDeptID", "88")
        }
        GlobalApplication.distDeptID = XmlUtil.readFileSdcard("DistDeptID")
        val kv = MMKV.defaultMMKV()
        val ip = kv.decodeString("cIp", UrlUtil.host2)
        setNetConfig("http://$ip:8181", 6, RequestHandler(this))
        NetworkUtils.registerNetworkStatusChangedListener(object : OnNetworkStatusChangedListener {
            override fun onDisconnected() {
                toast("网络已断开，请检查网络")
            }

            override fun onConnected(networkType: NetworkType) {
                toast("网络已连接")
            }
        })
    }
}